package stack.offer.simple;

import java.util.Stack;

public class LCOF_30 {
    Stack<Integer> stack = new Stack<>();
    public void push(int x) {
        if (stack.isEmpty() || stack.peek() > x) {
            stack.push(x);
            stack.push(x);
        } else if (stack.peek() <= x) {
            Integer peek = stack.peek();
            stack.push(x);
            stack.push(peek);
        }
    }

    public void pop() {
        stack.pop();
        stack.pop();
    }

    public int top() {
        Integer pop = stack.pop();
        Integer peek = stack.peek();
        stack.push(pop);
        return peek;
    }

    public int min() {
        return stack.peek();
    }
}
